﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Xml.Linq;
using System.Collections.Generic;
using LUStationery.Model;
using LUStationery.DAO;
namespace LUStationery.Controller
{

    public class CategoryListControl
    {
        public CategoryList getCategories()
        {
            CategoryDAO cDAO = new CategoryDAO();
            IDataReader idr = cDAO.getCategory();
            return CategoryListControl.convertIdrToCategoryList(idr);
        }

        protected static CategoryList convertIdrToCategoryList(IDataReader idr)
        {
            CategoryList cList = new CategoryList();
            while (idr.Read())
            {
                Category c = new Category();
                c.CategoryDesc = Convert.ToString(idr["category"]);
                cList.Add(c);
            }
            return cList;
        }

        protected static Category convertIdrToCategory(IDataReader idr)
        {
            Category c = new Category();
            while (idr.Read())
            {   
                c.CategoryDesc = Convert.ToString(idr["category"]);
            }
            return c;
        }
    }
}